package codename.carrot.bomberman.views.widgets;

import java.util.ArrayList;

import android.graphics.Canvas;
import sheep.gui.Widget;
import sheep.gui.WidgetAction;
import sheep.gui.WidgetListener;

/**
 * Abstract class that extends Sheep's <code>Widget</code> class. 
 * @author Group A4
 *
 */
public abstract class BombermanWidget extends Widget {
	
	/**
	 * Private list of listeners on a widget.
	 */
	private ArrayList<WidgetListener> widgetListeners = new ArrayList<WidgetListener>();

	@Override
	public void draw(Canvas canvas) {}

	@Override
	public void addWidgetListener(WidgetListener listener) {
		widgetListeners.add(listener);
	}

	@Override
	public void removeWidgetListener(WidgetListener listener) {
		widgetListeners.add(listener);
	}
	/**
	 * Used to alert all attached listeners about an action
	 * @param action - the action performed
	 */
	protected void alertListeners(WidgetAction action){
		for (WidgetListener listener: widgetListeners)
			listener.actionPerformed(action);
	}

	

}
